home *** CD-ROM | disk | FTP | other *** search
/ ShareWare OnLine 2 / ShareWare OnLine Volume 2 (CMS Software)(1993).iso / prog / fpclib36.zip / INCLUDE / FPCWIN.H < prev   
C/C++ Source or Header  |  1993-03-25  |  19KB  |  616 lines

  1. /*--------------------------------------------------------------------
  2. -                     Copyright (C) 1988-1992
  3. -                         SimpleSoft Inc.
  4. -
  5. - Written by..... Kevin Dahl
  6. - Module name.... fpwin.h
  7. - Date created... 5/5/91
  8. - Purpose........
  9. -
  10. --------------------------------------------------------------------*/
  11.  
  12. #ifndef FPCWIN
  13. #define FPCWIN
  14.  
  15. #include <stdlib.h>
  16. #include <stdio.h>
  17. #include <string.h>
  18. #include <conio.h>
  19. #include <malloc.h>
  20. #include <dos.h>
  21. #include <time.h>
  22. #include <conio.h>
  23. #include <fpclib.h>
  24.  
  25. /*--------------------------------------------------------------------
  26. -
  27. --------------------------------------------------------------------*/
  28.  
  29. typedef          char    CHAR;     /* ch  */
  30. typedef          short   SHORT;    /* s   */
  31. typedef          long    LONG;     /* l   */
  32.  
  33. typedef unsigned char    UCHAR;    /* uch */
  34. typedef unsigned short   USHORT;   /* us  */
  35. typedef unsigned long    ULONG;    /* ul  */
  36.  
  37. typedef unsigned char    BYTE;     /* b   */
  38.  
  39. typedef unsigned char   *PSZ;
  40. typedef unsigned char   *PCH;
  41.  
  42. typedef BYTE            *PBYTE;
  43.  
  44. typedef CHAR            *PCHAR;
  45. typedef SHORT           *PSHORT;
  46. typedef LONG            *PLONG;
  47.  
  48. typedef UCHAR           *PUCHAR;
  49. typedef USHORT          *PUSHORT;
  50. typedef ULONG           *PULONG;
  51.  
  52. typedef unsigned short   BOOL;        /* f         */
  53. typedef BOOL            *PBOOL;
  54.  
  55. typedef unsigned short   SHANDLE;
  56. typedef VOID FAR        *LHANDLE;
  57. typedef VOID FAR        *MPARAM;      /* msg param */
  58.  
  59. typedef LHANDLE          HWND;        /* hwnd      */
  60. typedef HWND            *PHWND;
  61. typedef LHANDLE          HMQ;         /* hmq       */
  62. typedef LHANDLE          HAB;         /* hab       */
  63.  
  64. typedef VOID FAR        *MPARAM;      /* mp        */
  65. typedef MPARAM FAR      *PMPARAM;     /* pmp       */
  66.  
  67. typedef VOID FAR        *MRESULT;     /* mres      */
  68. typedef MRESULT FAR     *PMRESULT;    /* pmres     */
  69.  
  70. typedef USHORT           HMODULE;     /* hmod      */
  71. typedef HMODULE FAR     *PHMODULE;
  72.  
  73. typedef VOID FAR        *PVOID;
  74.  
  75. /*--------------------------------------------------------------------
  76. -
  77. --------------------------------------------------------------------*/
  78.  
  79. #define INT_TIMER               0x08
  80. #define INT_KBD                 0x09
  81. #define INT_BIOSKBD             0x16
  82.  
  83. #define SYSQMAXEVENTS           50
  84. #define DEFAULT_QUEUE_SIZE      10;
  85.  
  86. /*--------------------------------------------------------------------
  87. -
  88. --------------------------------------------------------------------*/
  89.  
  90. #define TRUE                    (BOOL) 1
  91. #define FALSE                   (BOOL) 0
  92.  
  93. /*--------------------------------------------------------------------
  94. - MouGetEventMask/MouSetEventMask events
  95. --------------------------------------------------------------------*/
  96.  
  97. #define MOUSE                   0x007f
  98. #define MOUSE_MOTION            0x0001
  99. #define MOUSE_BN1_DOWN          0x0002
  100. #define MOUSE_BN1_UP            0x0004
  101. #define MOUSE_BN2_DOWN          0x0008
  102. #define MOUSE_BN2_UP            0x0010
  103. #define MOUSE_BN3_DOWN          0x0020
  104. #define MOUSE_BN3_UP            0x0040
  105.  
  106. #define MOUSE_BN_DOWN           0x002A
  107. #define MOUSE_BN_UP             0x0054
  108.  
  109. /*--------------------------------------------------------------------
  110. - Keyboard Shift Key masks.
  111. --------------------------------------------------------------------*/
  112.  
  113. #define INSKEY                  0x80
  114. #define CAPSLOCK                0x40
  115. #define NUMLOCK                 0x20
  116. #define SCROLLLOCK              0x10
  117. #define ALTKEY                  0x08
  118. #define CTRLKEY                 0x04
  119. #define BSHFTKEY                0x03
  120. #define LSHFTKEY                0x02
  121. #define RSHFTKEY                0x01
  122.  
  123. /*--------------------------------------------------------------------
  124. - Messages
  125. --------------------------------------------------------------------*/
  126.  
  127. #define WM_NULL                 0x0000
  128.  
  129.  
  130. #define WM_CLOSE                0x0029
  131. #define WM_QUIT         0x002a
  132.  
  133. /*--------------------------------------------------------------------
  134. - Mouse input messages
  135. --------------------------------------------------------------------*/
  136.  
  137. #define WM_MOUSEFIRST           0x0070
  138. #define WM_MOUSELAST            0x0079
  139.  
  140. #define WM_BUTTONCLICKFIRST    0x0071
  141. #define WM_BUTTONCLICKLAST    0x0079
  142.  
  143. #define WM_MOUSEMOVE        0x0070
  144. #define WM_BUTTON1DOWN          0x0071
  145. #define WM_BUTTON1UP            0x0072
  146. #define WM_BUTTON1DBLCLK        0x0073
  147. #define WM_BUTTON2DOWN          0x0074
  148. #define WM_BUTTON2UP        0x0075
  149. #define WM_BUTTON2DBLCLK    0x0076
  150. #define WM_BUTTON3DOWN          0x0077
  151. #define WM_BUTTON3UP        0x0078
  152. #define WM_BUTTON3DBLCLK    0x0079
  153.  
  154. /*--------------------------------------------------------------------
  155. - WM_HITTEST return codes
  156. --------------------------------------------------------------------*/
  157.  
  158. #define HT_NORMAL        0
  159. #define HT_TRANSPARENT        (-1)
  160. #define HT_DISCARD        (-2)
  161. #define HT_ERROR        (-3)
  162.  
  163. /*--------------------------------------------------------------------
  164. - Key/Character input messages
  165. --------------------------------------------------------------------*/
  166.  
  167. #define WM_CHAR                 0x007a
  168. #define WM_VIOCHAR        0x007b
  169.  
  170. /*--------------------------------------------------------------------
  171. - WM_CHAR fs field bits
  172. --------------------------------------------------------------------*/
  173.  
  174. #define KC_CHAR         0x0001
  175. #define KC_VIRTUALKEY           0x0002
  176. #define KC_SCANCODE             0x0004
  177. #define KC_SHIFT                0x0008
  178. #define KC_CTRL                 0x0010
  179. #define KC_ALT                  0x0020
  180. #define KC_KEYUP                0x0040
  181. #define KC_PREVDOWN             0x0080
  182. #define KC_LONEKEY              0x0100
  183. #define KC_DEADKEY              0x0200
  184. #define KC_COMPOSITE            0x0400
  185. #define KC_INVALIDCOMP        0x0800
  186.  
  187. /*--------------------------------------------------------------------
  188. - Reserve a range of messages for help manager.  This range includes
  189. - public messages, defined below, and private ones, which need to be
  190. - reserved here to prevent clashing with application messages
  191. --------------------------------------------------------------------*/
  192.  
  193. #define WM_HELPBASE        0x0F00 /* Start of msgs for help manager */
  194. #define WM_HELPTOP        0x0FFF /* End of msgs for help manager     */
  195.  
  196. #define WM_USER         0x1000
  197.  
  198. /*--------------------------------------------------------------------
  199. - Virtual key values
  200. --------------------------------------------------------------------*/
  201.  
  202. #define VK_BUTTON1        0x01
  203. #define VK_BUTTON2        0x02
  204. #define VK_BUTTON3        0x03
  205. #define VK_BREAK        0x04
  206. #define VK_BACKSPACE        0x05
  207. #define VK_TAB            0x06
  208. #define VK_BACKTAB        0x07
  209. #define VK_NEWLINE        0x08
  210. #define VK_SHIFT        0x09
  211. #define VK_CTRL         0x0A
  212. #define VK_ALT            0x0B
  213. #define VK_ALTGRAF        0x0C
  214. #define VK_PAUSE        0x0D
  215. #define VK_CAPSLOCK        0x0E
  216. #define VK_ESC            0x0F
  217. #define VK_SPACE        0x10
  218. #define VK_PAGEUP        0x11
  219. #define VK_PAGEDOWN        0x12
  220. #define VK_END            0x13
  221. #define VK_HOME         0x14
  222. #define VK_LEFT         0x15
  223. #define VK_UP            0x16
  224. #define VK_RIGHT        0x17
  225. #define VK_DOWN         0x18
  226. #define VK_PRINTSCRN        0x19
  227. #define VK_INSERT        0x1A
  228. #define VK_DELETE        0x1B
  229. #define VK_SCRLLOCK        0x1C
  230. #define VK_NUMLOCK        0x1D
  231. #define VK_ENTER        0x1E
  232. #define VK_SYSRQ        0x1F
  233. #define VK_F1            0x20
  234. #define VK_F2            0x21
  235. #define VK_F3            0x22
  236. #define VK_F4            0x23
  237. #define VK_F5            0x24
  238. #define VK_F6            0x25
  239. #define VK_F7            0x26
  240. #define VK_F8            0x27
  241. #define VK_F9            0x28
  242. #define VK_F10            0x29
  243. #define VK_F11            0x2A
  244. #define VK_F12            0x2B
  245. #define VK_F13            0x2C
  246. #define VK_F14            0x2D
  247. #define VK_F15            0x2E
  248. #define VK_F16            0x2F
  249. #define VK_F17            0x30
  250. #define VK_F18            0x31
  251. #define VK_F19            0x32
  252. #define VK_F20            0x33
  253. #define VK_F21            0x34
  254. #define VK_F22            0x35
  255. #define VK_F23            0x36
  256. #define VK_F24            0x37
  257.  
  258. #define VK_MENU                 VK_F10
  259.  
  260. #define VK_DBCSFIRST            0x0080
  261. #define VK_DBCSLAST        0x00ff
  262.  
  263. #define VK_USERFIRST        0x0100
  264. #define VK_USERLAST        0x01ff
  265.  
  266. /*--------------------------------------------------------------------
  267. - system variable access contants.
  268. --------------------------------------------------------------------*/
  269.  
  270. #define SV_SWAPBUTTON           0
  271. #define SV_DBLCLKTIME        1
  272. #define SV_CXDBLCLK        2
  273. #define SV_CYDBLCLK        3
  274. #define SV_CXSIZEBORDER     4
  275. #define SV_CYSIZEBORDER     5
  276. #define SV_ALARM        6
  277.  
  278. /*--------------------------------------------------------------------
  279. - WinPeekMsg() constants
  280. --------------------------------------------------------------------*/
  281.  
  282. #define PM_REMOVE        0x0001
  283. #define PM_NOREMOVE        0x0000
  284.  
  285. /*--------------------------------------------------------------------
  286. -
  287. --------------------------------------------------------------------*/
  288.  
  289. #define HWND_DESKTOP            (HWND)1
  290. #define HWND_OBJECT        (HWND)2
  291. #define HWND_TOP                (HWND)3
  292. #define HWND_BOTTOM        (HWND)4
  293. #define HWND_THREADCAPTURE      (HWND)5
  294.  
  295. /*--------------------------------------------------------------------
  296. - Standard Window Styles
  297. --------------------------------------------------------------------*/
  298.  
  299. #define WS_VISIBLE        0x80000000L
  300. #define WS_DISABLED        0x40000000L
  301. #define WS_CLIPCHILDREN     0x20000000L
  302. #define WS_CLIPSIBLINGS     0x10000000L
  303. #define WS_PARENTCLIP        0x08000000L
  304. #define WS_SAVEBITS        0x04000000L
  305. #define WS_SYNCPAINT        0x02000000L
  306. #define WS_MINIMIZED        0x01000000L
  307. #define WS_MAXIMIZED        0x00800000L
  308.  
  309. /*--------------------------------------------------------------------
  310. - Dialog manager styles
  311. --------------------------------------------------------------------*/
  312.  
  313. #define WS_GROUP        0x00010000L
  314. #define WS_TABSTOP        0x00020000L
  315. #define WS_MULTISELECT        0x00040000L
  316.  
  317. /*--------------------------------------------------------------------
  318. - Class styles
  319. --------------------------------------------------------------------*/
  320.  
  321. #define CS_MOVENOTIFY        0x00000001L
  322. #define CS_SIZEREDRAW        0x00000004L
  323. #define CS_HITTEST        0x00000008L
  324. #define CS_PUBLIC        0x00000010L
  325. #define CS_FRAME        0x00000020L
  326. #define CS_CLIPCHILDREN     0x20000000L
  327. #define CS_CLIPSIBLINGS     0x10000000L
  328. #define CS_PARENTCLIP        0x08000000L
  329. #define CS_SAVEBITS        0x04000000L
  330. #define CS_SYNCPAINT        0x02000000L
  331.  
  332. /*--------------------------------------------------------------------
  333. - Standard Window Messages
  334. --------------------------------------------------------------------*/
  335.  
  336. #define WM_CREATE               0x0001
  337. #define WM_DESTROY        0x0002
  338. #define WM_OTHERWINDOWDESTROYED 0x0003
  339. #define WM_ENABLE               0x0004
  340. #define WM_SHOW         0x0005
  341. #define WM_MOVE         0x0006
  342. #define WM_SIZE         0x0007
  343. #define WM_ADJUSTWINDOWPOS    0x0008
  344. #define WM_CALCVALIDRECTS       0x0009
  345. #define WM_SETWINDOWPARAMS      0x000a
  346. #define WM_QUERYWINDOWPARAMS    0x000b
  347. #define WM_HITTEST        0x000c
  348. #define WM_ACTIVATE        0x000d
  349. #define WM_SETFOCUS        0x000f
  350. #define WM_SETSELECTION     0x0010
  351.  
  352. /*--------------------------------------------------------------------
  353. -
  354. --------------------------------------------------------------------*/
  355.  
  356. typedef enum _WINDOW_CLASS
  357.    {
  358.    WC_FRAME,
  359.    WC_BUTTON,
  360.    WC_ENTRYFIELD,
  361.    WC_LISTBOX,
  362.    WC_MENU,
  363.    WC_SCROLLBAR,
  364.    WC_STATIC,
  365.    WC_TITLE
  366.    } CLASS;
  367.  
  368. /*--------------------------------------------------------------------
  369. -
  370. --------------------------------------------------------------------*/
  371.  
  372. #define EXPENTRY pascal far _loadds
  373. #define APIENTRY pascal far
  374.  
  375. /*--------------------------------------------------------------------
  376. -
  377. --------------------------------------------------------------------*/
  378.  
  379. typedef struct _POINTL                /* ptl       */
  380.    {
  381.    SHORT                 x;
  382.    SHORT                 y;
  383.    } POINTL;
  384.  
  385. /*--------------------------------------------------------------------
  386. - The following structure and macro are used to access the
  387. - WM_COMMAND, WM_HELP, and WM_SYSCOMMAND message parameters:
  388. --------------------------------------------------------------------*/
  389.  
  390. typedef struct _COMMANDMSG               /* commandmsg */
  391.    {
  392.    USHORT                source;         /* mp2 */
  393.    BOOL                  fMouse;
  394.    USHORT                cmd;            /* mp1 */
  395.    USHORT                unused;
  396.    } CMDMSG;
  397.  
  398. /*--------------------------------------------------------------------
  399. - The following structure and macro are used to access the
  400. - WM_MOUSEMOVE, and WM_BUTTON message parameters
  401. --------------------------------------------------------------------*/
  402.  
  403. typedef struct _MOUSEMSG                   /* mousemsg */
  404.    {
  405.    USHORT                codeHitTest;      /* mp2  */
  406.    USHORT                unused;
  407.    SHORT                 x;                /* mp1  */
  408.    SHORT                 y;
  409.    } MSEMSG;
  410.  
  411. /*--------------------------------------------------------------------
  412. - The following structure and macro are used to access the
  413. - WM_CHAR message parameters.
  414. --------------------------------------------------------------------*/
  415.  
  416. typedef struct _CHARMSG               /* charmsg */
  417.    {
  418.    USHORT                chr;         /* mp2  */
  419.    USHORT                vkey;
  420.    USHORT                fs;          /* mp1  */
  421.    UCHAR                 cRepeat;
  422.    UCHAR                 scancode;
  423.    } CHRMSG;
  424.  
  425. /*--------------------------------------------------------------------
  426. - QMSG structure
  427. --------------------------------------------------------------------*/
  428.  
  429. typedef struct _QMSG
  430.    {
  431.    HWND                  hwnd;
  432.    USHORT                msg;
  433.    MPARAM                mp1;
  434.    MPARAM                mp2;
  435.    ULONG                 time;
  436.    POINTL                ptl;
  437.    } QMSG;
  438.  
  439. /*--------------------------------------------------------------------
  440. - structure for message queue
  441. --------------------------------------------------------------------*/
  442.  
  443. typedef struct _MSGQUEUE_t
  444.    {
  445.    QMSG                 *MsgQ;
  446.    SHORT                 MaxEvents;
  447.    SHORT                 NEvents;          /* number of events|msgs   */
  448.    SHORT                 CEvent;           /* next pos to place event */
  449.    } MSGQUEUE_t;
  450.  
  451. /*--------------------------------------------------------------------
  452. - structure for message queues
  453. --------------------------------------------------------------------*/
  454.  
  455. typedef struct _MSGQ_t
  456.    {
  457.    MSGQUEUE_t            SysQ;
  458.    MSGQUEUE_t            AppQ;
  459.    QMSG                  PaintMsg;
  460.    USHORT                ShiftKeys;
  461.    } MSGQ_t;
  462.  
  463.  
  464. /*--------------------------------------------------------------------
  465. -
  466. --------------------------------------------------------------------*/
  467.  
  468. typedef struct _CLASSDEF_t
  469.    {
  470.  
  471.    struct _CLASSDEF_t   *Next;
  472.           CLASS          class;
  473.           CLASS          base;
  474.  
  475.           BYTE          *CWindow;
  476.           BYTE          *CSelected;
  477.           BYTE          *CFrame;
  478.  
  479.           ULONG          Style;
  480.  
  481.           HAB            hab;
  482.           PSZ            pszClassName;
  483.           MRESULT        (EXPENTRY *PFNWP)(HWND, USHORT, MPARAM, MPARAM);
  484.  
  485.           USHORT         cbWindowData;
  486.    } CLASSDEF_t;
  487.  
  488. /*--------------------------------------------------------------------
  489. -
  490. --------------------------------------------------------------------*/
  491.  
  492. typedef struct _WINDOW_t
  493.    {
  494.    struct _WINDOW_t     *Next;
  495.  
  496.           PCHAR          WinClass;
  497.           PCHAR          WinName;
  498.  
  499.    struct _WINDOW_t     *WinOwner;
  500.    struct _WINDOW_t     *WinParent;
  501.  
  502.    struct _WINDOW_t     *WinFirstChild;
  503.    struct _WINDOW_t     *WinLastChild;
  504.  
  505.    struct _WINDOW_t     *WinPrevSibling;
  506.    struct _WINDOW_t     *WinNextSibling;
  507.  
  508.           SHORT          Winx;          // horizontal position of window
  509.           SHORT          Winy;          // vertical position of window
  510.           SHORT          Wincx;         // width of window
  511.           SHORT          Wincy;         // height of window
  512.  
  513.           ULONG          WinStyle;
  514.           USHORT         WinIdent;
  515.  
  516.           SHORT          WinDataAmt;
  517.           PVOID          WinData;
  518.  
  519.    } WINDOW_t;
  520.  
  521.  
  522. /*--------------------------------------------------------------------
  523. -
  524. --------------------------------------------------------------------*/
  525.  
  526. typedef CMDMSG     FAR *  PCMDMSG;
  527. typedef POINTL     FAR *  PPOINTL;
  528. typedef MSEMSG     FAR *  PMSEMSG;
  529. typedef CHRMSG     FAR *  PCHRMSG;
  530. typedef QMSG       FAR *  PQMSG;
  531. typedef MSGQUEUE_t FAR *  PMSGQUEUE_t;
  532. typedef MSGQ_t     FAR *  PMSGQ_t;
  533. typedef CLASSDEF_t FAR *  PCLASSDEF_t;
  534. typedef WINDOW_t   FAR *  PWINDOW_t;
  535.  
  536. /*--------------------------------------------------------------------
  537. - one handle anchor block is created for each thread
  538. --------------------------------------------------------------------*/
  539.  
  540. typedef struct _GLOBAL_HAB_t
  541.    {
  542.    struct _GLOBAL_HAB_t *Next;
  543.    struct _GLOBAL_HAB_t *Prev;
  544.           PCHAR          PgmName;             /* program name              */
  545.           PMSGQ_t        MsgQ;                /* message queues            */
  546.           PWINDOW_t      WinFocus;            /* window that has the focus */
  547.           PWINDOW_t      DeskTop;
  548.           PWINDOW_t      DeskTopObj;
  549.           PCLASSDEF_t    ClassDef;
  550.  
  551.    } GLOBAL_HAB_t;
  552.  
  553. typedef GLOBAL_HAB_t FAR *  PGLOBAL_HAB_t;
  554.  
  555. /*--------------------------------------------------------------------
  556. - global variables for fpwin.
  557. --------------------------------------------------------------------*/
  558.  
  559. extern PGLOBAL_HAB_t  ghabHead;
  560. extern PGLOBAL_HAB_t  ghab;
  561. extern PGLOBAL_HAB_t  ghabTail;
  562. extern SHORT          gSysVal[];
  563.  
  564.  
  565. /*--------------------------------------------------------------------
  566. -
  567. - MODULE: queues.c
  568. -
  569. --------------------------------------------------------------------*/
  570.  
  571. HAB  APIENTRY WinInitialize( USHORT fsOptions );
  572. BOOL APIENTRY WinTerminate( HAB hab );
  573.  
  574. BOOL APIENTRY WinPeekMsg( HAB     syshab,
  575.                           PQMSG   pqmsg,
  576.                           HWND    hwndFilter,
  577.                           USHORT  msgFilterFirst,
  578.                           USHORT  msgFilterLast,
  579.                           USHORT  fs );
  580.  
  581. BOOL APIENTRY WinGetMsg(  HAB     hab,
  582.                           PQMSG   qmsg,
  583.                           HWND    hwndFilter,
  584.                           USHORT  msgFilterFirst,
  585.                           USHORT  msgFilterLast );
  586.  
  587. HMQ  APIENTRY WinCreateMsgQueue( HAB hab, SHORT cmsg );
  588. BOOL APIENTRY WinDestroyMsgQueue( HMQ hmq );
  589. BOOL APIENTRY WinPostMsg( HWND hwnd, USHORT msg, MPARAM mp1, MPARAM mp2 );
  590.  
  591. /*--------------------------------------------------------------------
  592. -
  593. - MODULE: dynarray.c
  594. -
  595. --------------------------------------------------------------------*/
  596.  
  597. SHORT ExpandArray( PVOID *Array, SHORT ElmtSize,
  598.                    SHORT NElmts, PSHORT LastElmt );
  599.  
  600. VOID  ShrinkArray( PVOID *Array, SHORT ElmtSize,
  601.                    SHORT NElmts, PSHORT LastElmt );
  602.  
  603. VOID  Release( PVOID *Node );
  604.  
  605. /*--------------------------------------------------------------------
  606. -
  607. - MODULE: window.c
  608. -
  609. --------------------------------------------------------------------*/
  610.  
  611. typedef MRESULT (EXPENTRY *PFNWP)(HWND, USHORT, MPARAM, MPARAM);
  612.  
  613.  
  614.  
  615. #endif
  616.